<template>
    <div class="child">
        <h2>子组件2</h2>
        <h3>{{toy}}</h3>
        <h3>哥哥的{{ computer}}</h3>
    </div>
</template>
<script lang="ts" setup>
import {ref,onUnmounted} from 'vue'
import emitter from "../../utils/emitter"

let toy = ref('小猪佩奇')
let computer = ref('')

emitter.on('send-toy',(value:any)=>{
   computer.value = value
})

onUnmounted(()=>{
    emitter.off('send-toy')
})
</script>
<style scoped>
.child {
    background-color: rgb(209, 116, 76);
    padding: 10px;
    box-shadow: 0 0 10px black;
    border-radius: 10px;
    margin-top: 20px;
}
</style>